/**
 * 
 */
package com.fita.api.handler.impl;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.fita.api.handler.QiniuHandler;
import com.qiniu.util.Auth;

/**
 * @author Guangli Yan
 *
 */
@Component("qiniuHandler")
public class QiniuHandlerImpl implements QiniuHandler{

    @Value("#{cloud['cloud.qiniu.accesskey']}")
	private String accessKey;
	
    @Value("#{cloud['cloud.qiniu.secretkey']}")
	private String secretKey;
	
    @Value("#{cloud['cloud.qiniu.bucket']}")
	private String bucket;
	
	
	/* (non-Javadoc)
	 * @see com.fita.api.handler.QiniuHandler#getToken()
	 */
	public String getToken() {
		
		Auth auth = Auth.create(accessKey, secretKey);
		
		String upToken = auth.uploadToken(bucket);
		
		return upToken;
	}

}
